package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.domain.TCertificateDocument;
import com.ruoyi.domain.THighwayConstructionSupervisionAuxiliary;
import com.ruoyi.domain.THighwayConstructionSupervisionAuxiliaryAttach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.THighwayConstructionSupervisionAuxiliaryMapper;
import com.ruoyi.service.ITHighwayConstructionSupervisionAuxiliaryService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 公路建设监督系统辅助信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@Service
public class THighwayConstructionSupervisionAuxiliaryServiceImpl implements ITHighwayConstructionSupervisionAuxiliaryService 
{
    @Autowired
    private THighwayConstructionSupervisionAuxiliaryMapper tHighwayConstructionSupervisionAuxiliaryMapper;
    @Autowired
    private THighwayConstructionSupervisionAuxiliaryAttach tHighwayConstructionSupervisionAuxiliaryAttach;
    /**
     * 查询公路建设监督系统辅助信息
     * 
     * @param id 公路建设监督系统辅助信息主键
     * @return 公路建设监督系统辅助信息
     */
    @Override
    public THighwayConstructionSupervisionAuxiliary selectTHighwayConstructionSupervisionAuxiliaryById(Long id)
    {
        return tHighwayConstructionSupervisionAuxiliaryMapper.selectTHighwayConstructionSupervisionAuxiliaryById(id);
    }

    /**
     * 查询公路建设监督系统辅助信息列表
     * 
     * @param tHighwayConstructionSupervisionAuxiliary 公路建设监督系统辅助信息
     * @return 公路建设监督系统辅助信息
     */
    @Override
    public List<THighwayConstructionSupervisionAuxiliary> selectTHighwayConstructionSupervisionAuxiliaryList(THighwayConstructionSupervisionAuxiliary tHighwayConstructionSupervisionAuxiliary)
    {
        return tHighwayConstructionSupervisionAuxiliaryMapper.selectTHighwayConstructionSupervisionAuxiliaryList(tHighwayConstructionSupervisionAuxiliary);
    }
    @Override
    public List<THighwayConstructionSupervisionAuxiliaryAttach> selectAttachmentById(Long highwayConstructionSupervisionId) {

        return tHighwayConstructionSupervisionAuxiliaryMapper.selectAttachmentById(highwayConstructionSupervisionId);
    }

    /**
     * 新增公路建设监督系统辅助信息
     *
     * @param tHighwayConstructionSupervisionAuxiliary 公路建设监督系统辅助信息
     */
    @Transactional
    @Override
    public void insertTHighwayConstructionSupervisionAuxiliary(THighwayConstructionSupervisionAuxiliary tHighwayConstructionSupervisionAuxiliary)
    {
        tHighwayConstructionSupervisionAuxiliaryMapper.insertTHighwayConstructionSupervisionAuxiliary(tHighwayConstructionSupervisionAuxiliary);
        List<String> attachs = tHighwayConstructionSupervisionAuxiliary.getAttachs();
        Long highwayConstructionSupervisionId = tHighwayConstructionSupervisionAuxiliary.getId();
        if (attachs != null && !attachs.isEmpty()) {
            attachs.forEach(attach -> {
                // 附件路径
                tHighwayConstructionSupervisionAuxiliaryAttach.setAttach(attach);
                tHighwayConstructionSupervisionAuxiliaryAttach.setTHighwayConstructionSupervisionAuxiliaryId(highwayConstructionSupervisionId);

                // 附件上传路径
                tHighwayConstructionSupervisionAuxiliaryMapper.insertDocumentAttach(tHighwayConstructionSupervisionAuxiliaryAttach);
            });

        }

    }

    /**
     * 修改公路建设监督系统辅助信息
     * 
     * @param tHighwayConstructionSupervisionAuxiliary 公路建设监督系统辅助信息
     * @return 结果
     */
    @Override
    public int updateTHighwayConstructionSupervisionAuxiliary(THighwayConstructionSupervisionAuxiliary tHighwayConstructionSupervisionAuxiliary)
    {
        return tHighwayConstructionSupervisionAuxiliaryMapper.updateTHighwayConstructionSupervisionAuxiliary(tHighwayConstructionSupervisionAuxiliary);
    }

    /**
     * 批量删除公路建设监督系统辅助信息
     * 
     * @param ids 需要删除的公路建设监督系统辅助信息主键
     * @return 结果
     */
    @Override
    public int deleteTHighwayConstructionSupervisionAuxiliaryByIds(Long[] ids)
    {
        return tHighwayConstructionSupervisionAuxiliaryMapper.deleteTHighwayConstructionSupervisionAuxiliaryByIds(ids);
    }

    /**
     * 删除公路建设监督系统辅助信息信息
     * 
     * @param id 公路建设监督系统辅助信息主键
     * @return 结果
     */
    @Override
    public int deleteTHighwayConstructionSupervisionAuxiliaryById(Long id)
    {
        return tHighwayConstructionSupervisionAuxiliaryMapper.deleteTHighwayConstructionSupervisionAuxiliaryById(id);
    }

}
